<?php


namespace App\Http\ViewComposers;


use App\Models\AdminRole;
use App\Models\Nav;
use App\Models\Role;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;

class LeftComposers
{
    public function compose(View $view)
    {

//            $model = Nav::lists($type=2,$status=true,'tree');


        $role_id = AdminRole::where('admin_id', Auth::guard('admin')->user()->id)->value('role_id');

        $access = Role::where('id', $role_id)->value('access');

        $navs  = Nav::whereIn('id', json_decode($access, true))->orderBy('sort', 'asc')->get();
        $model = Nav::tree($navs);


        $view->with('model', $model);
    }
}